//
//  OtherEventMainLineViewController.m
//  Runone
//
//  Created by runone02 on 17/1/10.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "OtherEventMainLineViewController.h"
#import "AppDelegate.h"
#import "CommonUtilityjudge.h"

@interface OtherEventMainLineViewController ()
@property(nonatomic,strong)NSMutableArray *highLineArray;
@property(nonatomic,strong)NSMutableArray *roadUIDArray;
@end

@implementation OtherEventMainLineViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [_highLineArray removeAllObjects];
    [_roadUIDArray removeAllObjects];
    if (iPhone5) {
         self.preferredContentSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width - 155), 135);
    }else {
     self.preferredContentSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width - 155) / 2, 135);
    }
//    self.preferredContentSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width - 155) / 2, 135);
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"LineCell"];
    _highLineArray = [[NSMutableArray alloc] init];
//    _roadUIDArray  = [[NSMutableArray alloc] init];
    AppDelegate *myDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    for (HighwayMergeRoadRecordModel *highModel in myDelegate.HighWayRoadArray) {
        [_highLineArray addObject:highModel.RoadName];
//        [_roadUIDArray addObject:highModel.RoadUID];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _highLineArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellID=@"LineCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
    if (cell==nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
    }
    cell.textLabel.text = _highLineArray[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.LineBlock!=nil) {
      
        NSString *lineStr = _highLineArray[indexPath.row];
//        NSString *uidStr  = _roadUIDArray[indexPath.row];
        AppDelegate *myDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        HighwayMergeRoadRecordModel *model = myDelegate.HighWayRoadArray[indexPath.row];
        self.LineBlock(lineStr, model);
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
